//
//  DYShareVC.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/13.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYShareVC.h"
#import "DYShareView.h"
#import "DYInviteRecordsVC.h"

#import <ShareSDK/ShareSDK.h>
#import <ShareSDKUI/ShareSDK+SSUI.h>
#import <ShareSDKUI/SSUIShareActionSheetStyle.h>

@interface DYShareVC ()

@property (nonatomic,strong)DYShareView *shareView;

@end

@implementation DYShareVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
-(void)rightClick
{
    DYInviteRecordsVC *vc=[[DYInviteRecordsVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
-(void)dy_initData
{
    [super dy_initData];
    
    self.view.backgroundColor=[UIColor xhq_base];
    self.navigationItem.title=@"分享";
    [self createRightBarItem:nil titleString:@"邀请记录"];
}
-(void)dy_initUI
{
    [super dy_initUI];
    
    [self.view addSubview:self.shareView];
}

-(void)share
{
    NSMutableDictionary *shareParams = [[NSMutableDictionary alloc] init];
    
    [shareParams SSDKSetupShareParamsByText:@"邀您注册"
                                     images:@[[UIImage imageNamed:@"mine_guanyu"]]
                                        url:nil
                                      title:@"卡福智能管家"
                                       type:SSDKContentTypeAuto];
    
    [SSUIShareActionSheetStyle setCancelButtonLabelColor:[UIColor xhq_content]];
    
    
    [ShareSDK showShareActionSheet:nil
                             items:@[@(SSDKPlatformSubTypeWechatSession),
                                     @(SSDKPlatformSubTypeWechatTimeline),
                                     @(SSDKPlatformSubTypeQQFriend)]
                       shareParams:shareParams
               onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
                   switch (state) {
                       case SSDKResponseStateSuccess:
                           XHQHUDTEXT(@"分享成功");
                           break;
                       case SSDKResponseStateFail:
                           XHQHUDTEXT(@"分享失败");
                           break;
                       default:
                           break;
                   }
               }];
}
-(DYShareView *)shareView
{
    if (!_shareView) {
        _shareView=[[DYShareView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-kNavigationStatusHeight)];
        
        @weakify(self);
        _shareView.shareBlock = ^{
            @strongify(self);
            [self share];
        };
    }
    return _shareView;
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [self NavaigationColor:[UIColor xhq_base]];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
